package com.example.administrator.yuejian_15.fragment;


import android.app.Fragment;
import android.content.Intent;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.example.administrator.yuejian_15.R;
import com.example.administrator.yuejian_15.activity.LoginActivity;
import com.example.administrator.yuejian_15.activity.OrderActivity;
import com.example.administrator.yuejian_15.activity.UserSzActivity;
import com.example.administrator.yuejian_15.bean.MyBean;
import com.example.administrator.yuejian_15.listener.TListener;
import com.example.administrator.yuejian_15.model.MyModel;
import com.example.administrator.yuejian_15.service.Service;
import com.squareup.picasso.Picasso;


/**
 * A simple {@link Fragment} subclass.
 */
public class WdFragment extends BaseFragment implements View.OnClickListener {
    ImageView my_tx;

    TextView my_username,my_phone,my_email;

    LinearLayout my_dd,my_pj,my_sz,my_sc,my_kf,my_jy;

    Button my_tc;

    @Override
    void initView() {

        String uid =getid();

        my_tx = (ImageView)view.findViewById(R.id.my_tx);
        my_username = (TextView)view.findViewById(R.id.my_username);
        my_phone = (TextView)view.findViewById(R.id.my_phone);
        my_email =(TextView)view.findViewById(R.id.my_email);
        my_tc = (Button)view.findViewById(R.id.my_tc);



        my_sz = (LinearLayout)view.findViewById(R.id.my_sz);
        my_dd = (LinearLayout)view.findViewById(R.id.my_dd);

        MyModel myModel = new MyModel();
        myModel.myinfo(uid,myBeanTListener);

    }

    TListener<MyBean> myBeanTListener = new TListener<MyBean>() {
        @Override
        public void onResponse(MyBean myBean) {
            String username = myBean.getUusername();
            String phone = myBean.getUphone();
            String email =myBean.getUemail();
            String tx= Service.BASE_URL+"yuejian/public/static/yjimg/yjyonghuimg/"+myBean.getUpic();
            Picasso.with(getContext()).load(tx).resize(90,90).into(my_tx);
            my_username.setText(username);
            my_phone.setText(phone);
            my_email.setText(email);

        }

        @Override
        public void onFail(String msg) {

        }
    };

    @Override
    void initEvent() {
        my_tc.setOnClickListener(this);
        my_sz.setOnClickListener(this);
        my_dd.setOnClickListener(this);

    }

    @Override
    public void onClick(View view) {
        switch (view.getId()){
            case R.id.my_tc:
                Intent intent = new Intent(getContext(), LoginActivity.class);
                startActivity(intent);
                getActivity().finish();
                break;
            case R.id.my_sz:
                Intent intent1 = new Intent(getContext(), UserSzActivity.class);
                startActivity(intent1);
                break;
            case R.id.my_dd:
                Intent intent2 = new Intent(getContext(), OrderActivity.class);
                startActivity(intent2);
                break;
                
        }
    }

    @Override
    void initDate() {

    }

    public WdFragment() {
        // Required empty public constructor
    }


    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        setLayout_file(R.layout.fragment_wd );
        return super.onCreateView(inflater,container,savedInstanceState);
    }

}
